#pragma once

#include <memory>

#include <btBulletDynamicsCommon.h>
#include "physics_IRigid.h"
#include <physics_RigidParam.h>

class BulletRigid : public IPhysicsRigid {
public:
	BulletRigid(std::unique_ptr<btDiscreteDynamicsWorld> &rupWorld, RigidBodyParam &param);
	~BulletRigid();
	void AttachToWorld() override;
	void DetachFromWorld() override;
	btVector3 GetWorldCenterPos();
	void GetWorldCenterMatrix(float *pMatrix) override;
	void SetWorldCenterMatrix(float *pMatrix) override;
	void* GetPointer() override;
private:
	RigidBodyParam m_param;
	bool m_attached = false;
	std::unique_ptr<btCollisionShape> m_upShape;
	std::unique_ptr<btDefaultMotionState> m_upMotionState;
	std::unique_ptr<btRigidBody> m_upRigidBody;
	std::unique_ptr<btDiscreteDynamicsWorld> &m_rupWorld;
};
